/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Tables;

import Domain.Apartment;
import java.util.ArrayList;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
 *
 * @author Min0
 */
public class BookingApartmentTableModel extends DefaultTableModel
{
        private ArrayList<Apartment> data;

        public BookingApartmentTableModel()
        {
            data = new ArrayList<Apartment>();
        }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }



    public void setData(ArrayList<Apartment> data)
    {
        this.data = data;
    }

    public ArrayList<Apartment> getData() {
        return data;
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public int getRowCount()
    {
        if(data == null)
        {
            return 0;
        }
        else
        {
            return data.size();
        }
    }

    @Override
    public String getColumnName(int column) {
        String columnName = "";
        switch(column)
        {
            case 0:
            columnName = "Room No.";
            break;
            case 1:
            columnName = "Type";
            break;
            case 2:
            columnName = "Available";
            break;
            case 3:
            columnName = "Price";
            break;
        }
        return columnName;
    }



    @Override
    public Object getValueAt(int row, int column)
    {
        Object value = null;
        switch(column)
        {
            case 0:
                value = data.get(row).getApartmentNo();
                break;
            case 1:
                value = data.get(row).getDescription();
                break;
            case 2:
                value = data.get(row).getAvailable();
                break;
            case 3:
                value = data.get(row).getPrice();
                break;
        }

        return value;
    }
}
